﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace DataLibrary
{
  public  class Ctbl_Hotro:IData<tbl_Hotro>
    {
      public Ctbl_Hotro(String myconnecString) : base(myconnecString) { }


      protected override int InsertOnSubmit(tbl_Hotro item, int t)
      {
          return connec.ExecuteNonQuery("ProHotro", CommandType.StoredProcedure, new SqlParameter("@flag", t),
              new SqlParameter("@"+tbl_Hotro.c_Description,item.Description),new SqlParameter("@"+tbl_Hotro.c_id,item.Id),
              new SqlParameter("@"+tbl_Hotro.c_Image,item.Image),new SqlParameter("@"+tbl_Hotro.c_isActive,item.IsActive),
              new SqlParameter("@"+tbl_Hotro.c_orderId,item.OrderId),new SqlParameter("@"+tbl_Hotro.c_Title,item.Title),
              new SqlParameter("@"+tbl_Hotro.c_Url,item.Url),new SqlParameter("@"+tbl_Hotro.c_IdTable,item.IdTable));
          
      }

      public override List<tbl_Hotro> GetAll(tbl_Hotro item)
      {
          throw new NotImplementedException();
      }

      public override tbl_Hotro GetItemById(object id)
      {
          return GetAll().SingleOrDefault(p => p.Id == Convert.ToInt32(id));
      }

      public override tbl_Hotro GetItem(IDataReader dr)
      {
          tbl_Hotro obj = new tbl_Hotro();
          obj.Description = dr[tbl_Hotro.c_Description].ToString();
          obj.Id =Convert.ToInt32(dr[tbl_Hotro.c_id].ToString());
          obj.Image = dr[tbl_Hotro.c_Image].ToString();
          obj.IsActive = Convert.ToInt32(dr[tbl_Hotro.c_isActive].ToString());
          obj.OrderId = Convert.ToInt32(dr[tbl_Hotro.c_orderId].ToString());
          obj.IdTable =dr[tbl_Hotro.c_IdTable].ToString();
          obj.Title = dr[tbl_Hotro.c_Title].ToString();
          obj.Url = dr[tbl_Hotro.c_Url].ToString();
          return obj;
      }

      public override List<tbl_Hotro> GetAll()
      {
          return GetAll("select * from " + tbl_Hotro.b_tbl_Hotro + this.strAsc, CommandType.Text);
      }
    }
}
